"""数据模块导出."""

from importlib import import_module
from types import ModuleType
from typing import TYPE_CHECKING

from .schemas import ETFHistoricalDataset, ETFMetadata, ETFRealtimeQuote

# 注意：不在这里导入 normalize_symbol，避免循环导入
# 如果需要使用 normalize_symbol，请直接从 src.utils 导入

__all__ = [
    "fetch_etf_history",
    "fetch_etf_intraday_price",
    "ETFHistoricalDataset",
    "ETFMetadata",
    "ETFRealtimeQuote",
]

_fetcher_module: ModuleType | None = None


def _load_fetcher() -> ModuleType:
    """延迟加载 ``src.data.fetcher`` 以避免运行时重复导入警告."""

    global _fetcher_module
    if _fetcher_module is None:
        _fetcher_module = import_module("src.data.fetcher")
    return _fetcher_module


def fetch_etf_history(*args, **kwargs):
    """调用 ``src.data.fetcher.fetch_etf_history``."""

    return _load_fetcher().fetch_etf_history(*args, **kwargs)


def fetch_etf_intraday_price(*args, **kwargs):
    """调用 ``src.data.fetcher.fetch_etf_intraday_price``."""

    return _load_fetcher().fetch_etf_intraday_price(*args, **kwargs)


if TYPE_CHECKING:
    from .fetcher import fetch_etf_history as fetch_etf_history
    from .fetcher import fetch_etf_intraday_price as fetch_etf_intraday_price

